package com.soso.taste.action;

import java.util.ArrayList;
import com.opensymphony.xwork2.ActionContext;
import com.soso.taste.service.TasteServiceImpl;

public class ShowAction{
	ActionContext context=ActionContext.getContext();
	
	private int nowpage;
	private int sumpage;
	private int max = 20;
	ArrayList<Object> objects;
	TasteServiceImpl ts = TasteServiceImpl.getInstance();
	public String  taste() {
		String tablename = "taste";
		int sum = ts.getSum(tablename);
		sumpage = (sum+max-1)/max;
		if(nowpage<=0){
	   		nowpage = 1;
		}else if(nowpage>sumpage){
			nowpage = sumpage;
		}else{}
		objects = ts.getLists(tablename, nowpage, max);
		//System.out.println("taste"+objects.size());
		return "success";
	}
	
	public String  amass() {
		String tablename = "amass";
		int sum = ts.getSum(tablename);
		sumpage = (sum+max-1)/max;
		if(nowpage<=0){
	   		nowpage = 1;
		}else if(nowpage>sumpage){
			nowpage = sumpage;
		}else{}
		objects = ts.getLists(tablename, nowpage, max);
		//System.out.println("amass"+objects.size());
		return "success";
	}
	
	public int getNowpage() {
		return nowpage;
	}

	public void setNowpage(int nowpage) {
		this.nowpage = nowpage;
	}

	public int getSumpage() {
		return sumpage;
	}

	public void setSumpage(int sumpage) {
		this.sumpage = sumpage;
	}

	public ArrayList<Object> getObjects() {
		return objects;
	}

	public void setObjects(ArrayList<Object> objects) {
		this.objects = objects;
	}

}
